Jan-Philipp Kolb
07 April 2016
Arten von räumlichen Daten:
Das R-paket ggmap wird im folgenden genutzt um verschiedene Kartentypen darzustellen.
Mit qmap kann man eine schnelle Karte erzeugen.
ggmap:install.packages("ggmap")Install packages
Install packages
librarylibrary(ggmap)Und schon kann die erste Karte erstellt werden:
qmap("Mannheim")BBT <- qmap("Berlin Brandenburger Tor")
BBTqmap("Germany")qmap("Germany", zoom = 6)?qmapVerschiedene Abschnitte in der Hilfe:
Ausschnitt aus der Hilfe Seite zum Befehl qmap:
qmap Example
Das Beispiel kann man direkt in die Konsole kopieren:
# qmap("baylor university")
qmap("baylor university", zoom = 14)
# und so weiterqmap("Mannheim", zoom = 12)qmap('Mannheim', zoom = 13)qmap('Mannheim', zoom = 20)qmap('Mannheim', zoom = 14, source="osm")qmap('Mannheim', zoom = 14, source="osm",color="bw")qmap('Mannheim', zoom = 14, maptype="satellite")qmap('Mannheim', zoom = 20, maptype="hybrid")qmap("Mannheim", zoom = 14, maptype="hybrid")Aus Physischen Karten kann man Informationen über Berge, Flüsse und Seen ablesen.
Farben werden oft genutzt um Höhenunterschiede zu visualisieren
qmap('Schriesheim', zoom = 14,
maptype="terrain")New York
Abstraktion wird genutzt um nur die essentiellen Informationen einer Karte zu zeigen.
Bsp. U-Bahn Karten - wichtig sind Richtungen und wenig Infos zur Orientierung
Im folgenden werden Karten vorgestellt, die sich gut als Hintergrundkarten eignen.
qmap('Mannheim', zoom = 14,
maptype="watercolor",source="stamen")qmap('Mannheim', zoom = 14,
maptype="toner",source="stamen")qmap('Mannheim', zoom = 14,
maptype="toner-lite",source="stamen")qmap('Mannheim', zoom = 14,
maptype="toner-hybrid",source="stamen")qmap('Mannheim', zoom = 14,
maptype="terrain-lines",source="stamen")RstudioExport
<- ist der Zuweisungspfeil um ein Objekt zu erzeugenMA_map <- qmap('Mannheim',
zoom = 14,
maptype="toner",
source="stamen")Geocoding (…) uses a description of a location, most typically a postal address or place name, to find geographic coordinates from spatial reference data …
library(ggmap)
geocode("Mannheim Wasserturm",source="google")| lon | lat |
|---|---|
| 34.79565 | 32.1221 |
| cities | lon | lat |
|---|---|---|
| Hamburg | 9.993682 | 53.55108 |
| Koeln | 6.960279 | 50.93753 |
| Dresden | 13.737262 | 51.05041 |
| Muenchen | 11.581981 | 48.13513 |
Reverse geocoding is the process of back (reverse) coding of a point location (latitude, longitude) to a readable address or place name. This permits the identification of nearby street addresses, places, and/or areal subdivisions such as neighbourhoods, county, state, or country.
Quelle: Wikipedia
revgeocode(c(48,8))## [1] "Unnamed Road, Somalia"
mapdist("Q1, 4 Mannheim","B2, 1 Mannheim")## from to m km miles seconds minutes
## 1 Q1, 4 Mannheim B2, 1 Mannheim 746 0.746 0.4635644 192 3.2
## hours
## 1 0.05333333
mapdist("Q1, 4 Mannheim","B2, 1 Mannheim",mode="walking")## from to m km miles seconds minutes
## 1 Q1, 4 Mannheim B2, 1 Mannheim 546 0.546 0.3392844 420 7
## hours
## 1 0.1166667
mapdist("Q1, 4 Mannheim","B2, 1 Mannheim",mode="bicycling")## from to m km miles seconds minutes
## 1 Q1, 4 Mannheim B2, 1 Mannheim 555 0.555 0.344877 215 3.583333
## hours
## 1 0.05972222
POI1 <- geocode("B2, 1 Mannheim",source="google")
POI2 <- geocode("Hbf Mannheim",source="google")
POI3 <- geocode("Wasserturm Mannheim",source="google")
ListPOI <-rbind(POI1,POI2,POI3)
POI1;POI2;POI3## lon lat
## 1 8.462844 49.48569
## lon lat
## 1 8.469879 49.47972
## lon lat
## 1 8.466039 49.48746
MA_map +
geom_point(aes(x = lon, y = lat),
data = ListPOI)MA_map +
geom_point(aes(x = lon, y = lat),col="red",
data = ListPOI)ListPOI$color <- c("A","B","C")
MA_map +
geom_point(aes(x = lon, y = lat,col=color),
data = ListPOI)ListPOI$size <- c(10,20,30)
MA_map +
geom_point(aes(x = lon, y = lat,col=color,size=size),
data = ListPOI)from <- "Mannheim Hbf"
to <- "Mannheim B2 , 1"
route_df <- route(from, to, structure = "route")qmap("Mannheim Hbf", zoom = 14) +
geom_path(
aes(x = lon, y = lat), colour = "red", size = 1.5,
data = route_df, lineend = "round"
)Wie fügt man Punkte hinzu
Nutzung von geom_point
Question on stackoverflow
pic
ggmap.http://journal.r-project.org/archive/2013-1/kahle-wickham.pdf
Was klar sein sollte: